package NC;

public class NC86 {
    public int[] findElement(int[][] mat, int n, int m, int x) {
        if(mat == null || mat.length != n || mat[0].length != m){
            return null;
        }
        int row = 0, col = m-1;
        while(row <= n-1 && col >= 0){
            if(mat[row][col] == x){
                return new int[]{row, col};
            }else if(mat[row][col] > x){
                col--;
            }else{
                row++;
            }
        }
        return null;
    }
}